<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<c:set var="defaultImg" value="${redis:getSysConfig('website_default_img')}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>商品品牌信息</title>
	<jsp:include page="../../../util/import.jsp"/>

	<script type="text/javascript">
        /**
         * 初始化Table
         */
        $(function(){
            var $tt= $("#tt").bootstrapTable({

                url: '${basePath}/back/brand/listBrand.sjson',       	/**请求后台的URL（*）**/
                method: 'post',                       	/**请求方式（*）**/
                contentType: "application/x-www-form-urlencoded",
                dataType: 'json',
                toolbar: '#toolbar',               	    /**工具按钮用哪个容器**/
                striped: true,                      	/**是否显示行间隔色**/
                cache: false,                       	/**是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）**/
                pagination: true,                   	/**是否显示分页（*）**/
                sortable: false,                    	/**是否启用排序**/
                sortOrder: 'asc',                   	/**排序方式**/
                queryParamsType: '',
                sidePagination: 'server',           	/**分页方式：client客户端分页，server服务端分页（*）**/
                pageNumber: 1,
                pageSize:10,							/**初始化加载第一页，默认第一页**/
                pageList: [5,10, 25, 50],        	    /**可供选择的每页的行数（*）**/
                search: false,                       	/**是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大**/
                strictSearch: true,
                showColumns: true,                  	/**是否显示所有的列**/
                showRefresh: true,                  	/**是否显示刷新按钮**/
                minimumCountColumns: 2,             	/**最少允许的列数**/
                clickToSelect: true,                	/**是否启用点击选中行**/
                uniqueId: 'brandId',                  	/**每一行的唯一标识，一般为主键列**/
                singleSelect  : true,                   /** 单选checkbox**/
                showToggle:false,                    	/**是否显示详细视图和列表视图的切换按钮**/
                cardView: false,                    	/**是否显示详细视图**/
                detailView: false,                  	/**是否显示父子表**/

                columns: [
                    {checkbox: true},
                    {field: 'Number', title: '编号',align: 'center',valign: 'middle',width:'50px',
                        formatter: function (value, row, index) {
                            var page = $tt.bootstrapTable("getPage");
                            return page.pageSize * (page.pageNumber - 1) + index + 1;
                        }
                    },
                    {field: 'brandName',title: '品牌名称',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            var  a_html = '<a data-toggle="modal" data-target="#detailModal" href="#" mce_href="#" onclick="detailInfo('+row.brandId+')">' + value + '</a>';
                            return a_html;
                        }
                    },
                    {field: 'brandImageUrl',title: '首页推荐品牌图片',align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            var  a_img_html='<div><a  data-toggle="modal" data-target="#detailModal" href="#" mce_href="#" onclick="showListRebackImage('+index+',1,1),detailInfo('+row.brandId+')"><img id="uploadImg_'+index+'" class="uploadImg" onMouseOver="showListBigImage('+index+',4,4,0,-40)" onMouseOut="showListRebackImage('+index+',1,1)"  src="${uploadPath}/'+row.brandImageUrl+'" onerror="this.src=\'${srcPath}/common/images/mrbj.png\'"  width="30px" height="30px"/></a></div>';
                            return a_img_html;
                        }
                    },
                    {field:"firstWord",title:"品牌归类",align: 'center',valign: 'middle'},
                    {field:"title",title:"标题",align: 'center',valign: 'middle'},
                    {field:"synopsis",title:"简介",align: 'center',valign: 'middle'},
                    {field:"isShow",title:"是否显示",align: 'center',valign: 'middle',
						formatter:function(value,row,index){
							if(value=="0"){ return "<font class='color_002'>未显示</font>";}
							if(value=="1"){ return "<font class='color_001'>已显示</font>";}
						}
                    },
                    {field:"isRecommend",title:"品牌墙推荐",align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value=="0"){ return "<font class='color_002'>未推荐</font>";}
                            if(value=="1"){ return "<font class='color_001'>已推荐</font>";}
                        }
                    },
                    {field:"isHomePage",title:"店铺品牌广告",align: 'center',valign: 'middle',
                        formatter:function(value,row,index){
                            if(value=="0"){ return "<font class='color_002'>未推荐</font>";}
                            if(value=="1"){ return "<font class='color_001'>已推荐</font>";}
                        }
                    }
                ],
                queryParams: function (params) {
                    /**特别说明，返回的参数的值为空，则当前参数不会发送到服务器端,这种指定请求参数的方式和datatables控价类似**/
                    params.brandName = $("#q_brandName").val();
                    params.isShow = $("#q_isShow").val();
                    params.isRecommend = $("#q_isRecommend").val();
                    params.isHomePage = $("#q_isHomePage").val();
                    params.firstWord = $("#q_firstWord").val();
                    params.currentPage = params.pageNumber;
                    return params;
                }

            });

        });

        /**
         * 删除分类
         */
        <shiro:hasPermission name="back_gotoBrandPage_delete">
        function deleteInfo(){
            /**获取选中行的id**/
            var selectedRow= $("#tt").bootstrapTable('getSelections');
            if(selectedRow.length==1){
                var id=selectedRow[0].brandId;
                showConfirm("你确定要删除吗?", function() {
                    $.ajax({
                        type: "POST",
                        dataType: "JSON",
                        url: "${basePath}/back/brand/deleteBrand.sjson",
                        data: {brandId:id},
                        success: function(data){
                            if(data.success==true){
                                $("#tt").bootstrapTable('refresh');
                            }
                        }
                    });
                });
            }else{
                showMsg("请选择一行记录！");
            }
        }
        </shiro:hasPermission>
	</script>

</head>
<body>
<div class="panel-body" id="customer-main-panel">
	<!-- 查询条件 -->
	<div class="panel panel-default">
		<div class="panel-heading">品牌信息查询</div>
		<div class="panel-body">
			<form id="qform" class="form-horizontal">
				<div class="form-group" style="margin-top:15px">
					<div class="col-sm-3">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">品牌名称</span>
							<input type="text" class="form-control" id="q_brandName" name="brandName" placeholder="请输入品牌名称"/>
						</div>
					</div>
					<div class="col-sm-3" style="width:240px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">是否显示</span>
							<select id="q_isShow" class="form-control">
								<option value="">--请选择--</option>
								<option value="0">未显示</option>
								<option value="1">已显示</option>
							</select>
						</div>
					</div>
					<div class="col-sm-3" style="width:240px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">品牌墙推荐</span>
							<select id="q_isRecommend" class="form-control">
								<option value="">--请选择--</option>
								<option value="0">未推荐</option>
								<option value="1">已推荐</option>
							</select>
						</div>
					</div>
					<div class="col-sm-3" style="width:240px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">店铺品牌广告</span>
							<select id="q_isHomePage" class="form-control">
								<option value="">--请选择--</option>
								<option value="0">未推荐</option>
								<option value="1">已推荐</option>
							</select>
						</div>
					</div>
					<div class="col-sm-3" style="width:240px;">
						<div class="input-group input-group-sm">
							<span class="input-group-addon">品牌归类</span>
							<select id="q_firstWord" class="form-control">
								<option value="">--请选择--</option>
								<option value="0">0</option>
								<option value="1">1</option>
								<option value="2">2</option>
								<option value="3">3</option>
								<option value="4">4</option>
								<option value="5">5</option>
								<option value="6">6</option>
								<option value="7">7</option>
								<option value="8">8</option>
								<option value="9">9</option>
								<option value="A">A</option>
								<option value="B">B</option>
								<option value="C">C</option>
								<option value="D">D</option>
								<option value="E">E</option>
								<option value="F">F</option>
								<option value="G">G</option>
								<option value="H">H</option>
								<option value="I">I</option>
								<option value="J">J</option>
								<option value="K">K</option>
								<option value="L">L</option>
								<option value="M">M</option>
								<option value="N">N</option>
								<option value="O">O</option>
								<option value="P">P</option>
								<option value="Q">Q</option>
								<option value="R">R</option>
								<option value="S">S</option>
								<option value="T">T</option>
								<option value="U">U</option>
								<option value="V">V</option>
								<option value="W">W</option>
								<option value="X">X</option>
								<option value="Y">Y</option>
								<option value="Z">Z</option>
							</select>
						</div>
					</div>
					<div class="col-sm-2">
						<button type="button" id="btn_query" class="btn btn-primary">查询</button>
						<button type="reset" class="btn btn-success" id="resetBtn">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>

	<!-- 工具栏 -->
	<div id="toolbar" class="btn-group">
		<shiro:hasPermission name="back_gotoBrandPage_add">
			<button id="btn_add" type="button" class="btn btn-default" data-toggle="modal" data-target="#addOrEditModal" onclick="addInfo()">
				<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoBrandPage_update">
			<button id="btn_edit" type="button" class="btn btn-default" data-toggle="modal"  onclick="editInfo()">
				<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
			</button>
		</shiro:hasPermission>

		<shiro:hasPermission name="back_gotoBrandPage_delete">
			<button id="btn_delete" type="button" class="btn btn-default" onclick="deleteInfo()">
				<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
			</button>
		</shiro:hasPermission>
	</div>

	<!-- 渲染的table -->
	<table id="tt"></table>
	<!-- 添加修改页面 -->
	<jsp:include page="addOrEdit.jsp"/>
	<!-- 详情页面 -->
	<jsp:include page="detail.jsp"/>
</div>

</body>
</html>